﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace CourierManager
{
    public static class ValidatorName
    {
        public static void PersonalFirstNameValidator(string firstName)
        {
            if ((!Regex.Match(firstName, @"^[a-zA-Z][a-zA-Z\._\-]{0,22}?[a-zA-Z]{0,2}$").Success))
            {
                throw new InvalidNameException("Invalid Person First Name!", firstName);
            }
        }

        public static void PersonalLastNameValidator(string lastName)
        {
            if ((!Regex.Match(lastName, @"^[a-zA-Z][a-zA-Z\._\-]{0,22}?[a-zA-Z]{0,2}$").Success))
                
            {
                throw new InvalidNameException("Invalid Person Last Name!",lastName);
            }
        }

        public static void CompanyNameValidator(string companyName)
        {
            if (!Regex.Match(companyName, @"\b[a-zA-Z][A-Z'a-z]\w+").Success)
            {
                throw new InvalidNameException("Invalid Company Name!", companyName);
            }
        }
    }
}
